#include <stdio.h>
#include <string.h>
#include <math.h>

char s1[110] , s2[110];
int tt[110][110];
int cc[110][110];
int len1,len2;
char an[220];
char out[220];
int na;


main()
{
	int i,j;
	int a,b;
	while (scanf("%s%s", s1, s2)!=EOF)
	{
		memset(tt,0,sizeof(tt));
		memset(cc,0,sizeof(cc));
		len1=strlen(s1);
		len2=strlen(s2);

		for (i=1;i<=len1;i++)
			for (j=1;j<=len2;j++)
				if (s1[i-1]==s2[j-1])
				{
					tt[i][j]=tt[i-1][j-1]+1;					
					cc[i][j]=1;
				}
				else
				{
					tt[i][j]=tt[i-1][j]>tt[i][j-1] ? (cc[i][j]=2,tt[i-1][j]) : (cc[i][j]=3,tt[i][j-1]);
				}
		na=0;
		a=len1;
		b=len2;
		while (cc[a][b]!=0)
		{
			if (cc[a][b]==1)
			{
				an[++na]=s1[a-1];
				a--;
				b--;
			}
			else if (cc[a][b]==2)
			{
				a--;
			}
			else if (cc[a][b]==3)
			{
				b--;
			}
		}

		memset(out,0,sizeof(out));
		int nout=0;
		char ch;
		int start1=0,start2=0;
		int la=0,lb=0;
		for (i=na;i>=1;i--)
		{
			ch=an[i];
			for ( ; start1<len1;start1++)
				if (s1[start1]==ch)
				{
					a=start1++;
					break;
				}
			for ( ; start2<len2;start2++)
				if (s2[start2]==ch)
				{
					b=start2++;
					break;
				}
			for (j=la;j<a;j++)
				out[++nout]=s1[j];
			for (j=lb;j<b;j++)
				out[++nout]=s2[j];
			out[++nout]=ch;				
			la=a+1;
			lb=b+1;
		} // end of for 
		for (j=la;j<len1;j++)
			out[++nout]=s1[j];
		for (j=lb;j<len2;j++)
			out[++nout]=s2[j];
		for (i=1;i<=nout;i++)
			printf("%c", out[i]);
		printf("\n");

	}
	return 0;
}
